package com.gams.springboot.dao;

import com.gams.springboot.pojo.Menu;
import com.gams.springboot.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author tql
 * @current springboot
 * @create 2021-09-9-10:11
 */
public interface MenuDao {
    //查询所有角色
    @Select("select * from sys_menu")
    List<Menu> selectAllMenu();

    @Select("select * from sys_menu where parentId=#{id}")
    List<Menu> selectParentId(long id);

    //新增菜单
    @Insert("insert into sys_menu(name," +
            "appUrl,sortCode,parentId,createTime,isMenu)values(#{name},#{appUrl}," +
            "#{sortCode},#{parentId},#{createTime},#{isMenu});")
    int addMenu(Menu menu);

    //修改菜单
    @Update("update sys_menu set name=#{name},appUrl=#{appUrl},sortCode=#{sortCode}," +
            "updateTime=#{updateTime},isMenu=#{isMenu} where id=#{id}")
    int updateMenu(Menu menu);

    //删除菜单
    @Delete("delete from sys_menu where id=#{id} ")
    int deleteMenu(long id);

    //根据角色Id查询所有菜单
    List<Menu> selectAllMenuByRoleId(long roleId);

    List<Menu> selectAllMenuByUserId(long userId);
}
